<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

	<title>备案登记</title>
	<link rel="stylesheet" href="assets/libs/layui/css/layui.css" />
	<style>
		@media screen and (min-width: 800px) {
			.layui-form-label{
				width: 86px !important;
			}
			.common_info{
				width: 300px !important;
			}
		}
		.content_box{
			max-width: 960px;
			display: flex;
			justify-content: center
		}

		.login-header {
			color: rgba(0, 0, 0, .85) !important;
			padding: 5% 0;
			text-align: center;
		}

		.buttongroup {
			display: flex;
			margin-top: 10%;
		}

		.buttongroup button {
			width: 100%;
			height: 45px;
		}

		.main_content_wrap {
			margin: 20px 0px;
		}
	</style>
</head>

<body>
	<div class="body">
		<div class="login-header">
			<h2 style="font-weight: 400;letter-spacing: 3px; font-size: 30px">备案登记</h2>
		</div>
		<div class="layui-fluid content_box">
			<div class="main_content_wrap">
				<form lay-filter="modifyForm" class="layui-form model-form">
					<div class="layui-form-item">
						<label class="layui-form-label">登记日期</label>
						<div class="layui-input-inline">
							<input type="text" name="sign_date" placeholder="YYYY-MM-DD" class="layui-input"
								   id='sign_date' required autocomplete="off">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">备注</label>
						<div class="layui-input-inline common_info">
							<textarea name="opt_common" id="opt_common" placeholder="请输入备注" class="layui-textarea"></textarea>
						</div>
					</div>
					<div class="layui-form-item text-center buttongroup">
						<button type="button" lay-filter="modifyFormSubmit" lay-submit
							class="layui-btn site-demo-active">提交</button>
					</div>
				</form>
			</div>
		</div>
	</div>
	<script type="text/javascript" src="assets/libs/layui/layui.js"></script>
	<script type="text/javascript" src="assets/js/config.js"></script>
	<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
	<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>

	<script src="https://wwcdn.weixin.qq.com/node/open/js/wecom-jssdk-1.3.1.js"></script>
	<script src="https://open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js" referrerpolicy="origin"></script>


	<script>
		layui.use(['jquery', 'form','layer', 'laydate'], function () {
			var $ = layui.jquery;
			var form = layui.form;
			var layer = layui.layer;
			var laydate = layui.laydate;

			var id = getUrlParam('id');
			var opt_type = getUrlParam('type');
			let userMsg = JSON.parse(localStorage.getItem("userMsg"));
			// 日期范围 - 左右面板独立选择模式
			laydate.render({
				elem: '#sign_date', //指定元素
				format: 'yyyy-MM-dd', //可任意组合
				trigger: 'click',
				value:new Date(),
				max:''
			});

			form.render();
			//监听提交
			form.on('submit(modifyFormSubmit)', function (data) {
				var DISABLED = 'layui-btn-disabled';
				// 增加样式
				$('.site-demo-active').addClass(DISABLED);
				// 增加属性
				$('.site-demo-active').attr('disabled', 'disabled');
				var form_data = data.field;
				form_data.opt_json_content = JSON.stringify(form_data);
				form_data.knowledge_id = id
				form_data.opt_type = opt_type
				form_data.opt_userid = userMsg.UserId;
				form_data.opt_deptment = Array.isArray(userMsg.department)?userMsg.department.join(','):userMsg.department;
				let newobj = typeChange(form_data);
				$.post(serverUrl + 'Knowledge/modifyInfo.html', newobj, function (res) {
					if (res.success === true) {
						layer.msg('提交成功', { icon: 1, time: 300 }, function () {
							window.location.href = `detail.html?id=`+id;
						});
					} else {
						layer.msg(res.msg, { icon: 2 });
						$('.site-demo-active').removeClass(DISABLED);
						$('.site-demo-active').removeAttr('disabled');
					}
				}, 'json');
				return false;
			});
		});
	</script>
</body>

</html>